package com.mt.repair.entity.repairManagement;

import javax.persistence.*;
import java.io.Serializable;

import com.mt.common.core.annotation.DColumn;
import com.mt.common.core.annotation.DEntity;
import com.mt.common.core.web.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;


import com.mt.common.system.entity.User;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@DEntity(label = "维修单", comment = "", moduleLabel = "报修管理")
@Entity(name = "repair_repair_order")
@Table(name = "repair_repair_order", indexes = {@Index(name = "index_repair_area", columnList = "repair_area"), @Index(name = "index_fault_type", columnList = "fault_type"), @Index(name = "index_repair_applicant_id", columnList = "repair_applicant_id"), @Index(name = "index_repair_applicant_phone", columnList = "repair_applicant_phone"), @Index(name = "index_repair_level", columnList = "repair_level")})
@ApiModel(description = "维修单:")
public class RepairOrder extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @DColumn(index = 3, label = "报修单号", comment = "报修单号", component = "文本", where = true)
    @ApiModelProperty(value = "报修单号:报修单号")
    @Column(name = "repair_code", length = 255, nullable = true, unique = false)
    private String repairCode;

    @DColumn(index = 3, label = "学校", comment = "学校", component = "文本", where = true)
    @ApiModelProperty(value = "学校:学校")
    @Column(name = "school", length = 255, nullable = false, unique = false)
    private String school;

    @DColumn(index = 4, label = "报修区域", codeTable = "报修区域", codeTableOptions = "教学区,寝室,未知", comment = "报修区域", component = "字典下拉单选", where = true)
    @ApiModelProperty(value = "报修区域:报修区域")
    @Column(name = "repair_area", length = 255, nullable = false, unique = false)
    private String repairArea;

    @DColumn(index = 5, label = "详细位置", comment = "宿舍就是具体宿舍号，教学楼就是对应教学楼", component = "文本", where = false)
    @ApiModelProperty(value = "详细位置:宿舍就是具体宿舍号，教学楼就是对应教学楼")
    @Column(name = "detailed_location", length = 255, nullable = false, unique = false)
    private String detailedLocation;


    @DColumn(index = 6, label = "故障类型", codeTable = "故障类型", codeTableOptions = "空调,水龙头,门,未知", comment = "故障类型", component = "字典下拉单选", where = true)
    @ApiModelProperty(value = "故障类型:故障类型")
    @Column(name = "fault_type", length = 255, nullable = false, unique = false)
    private String faultType;

    @DColumn(index = 7, label = "报修人", foreignEntity = "User", comment = "报修人", component = "对象选择", where = false)
    @ApiModelProperty(value = "报修人:报修人")
    @Column(name = "repair_applicant_id", length = 255, nullable = false, unique = false)
    private Long repairApplicantId;

    @Transient
    private User repairApplicant;

    @Transient
    @ApiModelProperty(value = "报修人名称:报修人")
    @DColumn(index = 7, label = "报修人", foreignEntity = "User", comment = "报修人")
    private String repairApplicantName;

    @DColumn(index = 8, label = "性别", codeTable = "性别", codeTableOptions = "男,女,未知", comment = "报修人电话", component = "文本", where = true)
    @ApiModelProperty(value = "性别:报修人电话")
    @Column(name = "repair_applicant_phone", length = 255, nullable = false, unique = false)
    private String repairApplicantPhone;

    @DColumn(index = 9, label = "预期上门维修时间", comment = "预期上门维修时间", component = "日期选择", where = true)
    @ApiModelProperty(value = "预期上门维修时间:预期上门维修时间")
    @Column(name = "expect_repair_time", length = 255, nullable = false, unique = false)
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date expectRepairTime;

    @DColumn(index = 10, label = "上门维修时间", comment = "维修时间", component = "日期选择", where = false)
    @ApiModelProperty(value = "上门维修时间:维修时间")
    @Column(name = "repair_time", length = 255, nullable = true, unique = false)
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date repairTime;

    @DColumn(index = 10, label = "接单时间", comment = "接单时间", component = "日期选择", where = false)
    @ApiModelProperty(value = "接单时间:接单时间")
    @Column(name = "receive_time", length = 255, nullable = true, unique = false)
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date receiveTime;

    @DColumn(index = 10, label = "评论时间", comment = "评论时间", component = "日期选择", where = false)
    @ApiModelProperty(value = "评论时间:评论时间")
    @Column(name = "evaluate_time", length = 255, nullable = true, unique = false)
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date evaluateTime;

    @DColumn(index = 10, label = "完成时间", comment = "完成时间", component = "日期选择", where = false)
    @ApiModelProperty(value = "完成时间:完成时间")
    @Column(name = "complete_time", length = 255, nullable = true, unique = false)
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date completeTime;

    @DColumn(index = 11, label = "故障图片", comment = "故障图片，为地址拼接，用逗号隔开", component = "文本", where = false)
    @ApiModelProperty(value = "故障图片:故障图片，为地址拼接，用逗号隔开")
    @Column(name = "fault_picture", length = 255, nullable = true, unique = false)
    private String faultPicture;

    @DColumn(index = 12, label = "维修级别", codeTable = "维修级别", codeTableOptions = "普通维修,紧急维修,未知", comment = "维修级别", component = "字典下拉单选", where = true)
    @ApiModelProperty(value = "维修级别:维修级别")
    @Column(name = "repair_level", length = 255, nullable = true, unique = false)
    private String repairLevel;

    @DColumn(index = 13, label = "当前状态编号", comment = "当前状态", component = "数字,整数", where = true)
    @ApiModelProperty(value = "当前状态编号:当前状态")
    @Column(name = "current_state", length = 255, nullable = false, unique = false)
    private Integer currentState;

    @DColumn(index = 7, label = "维修员", foreignEntity = "User", comment = "维修员", component = "对象选择", where = false)
    @ApiModelProperty(value = "维修员:维修员")
    @Column(name = "repairman_id", length = 255, nullable = false, unique = false)
    private Long repairmanId;

    @Transient
    private User repairman;

    @Transient
    @ApiModelProperty(value = "维修员名称:维修员名称")
    @DColumn(index = 7, label = "维修员", foreignEntity = "User", comment = "维修员")
    private String repairmanName;

    @Transient
    @ApiModelProperty(value = "维修员电话:维修员电话")
    @DColumn(index = 7, label = "维修员", foreignEntity = "User", comment = "维修员")
    private String repairmanPhone;

    @DColumn(index=3,label="故障设备",foreignEntity="Device",comment="设备",component="对象选择",where=false)
    @ApiModelProperty(value = "故障设备:故障设备")
    @Column(name="device_id",length=255,nullable=true,unique=false)
    private Long deviceId;

    @Transient
    private Device device;
    @Transient
    private String deviceType;
    @Transient
    private String deviceName;

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public Long getDeviceId() {
        return deviceId;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public void setDeviceId(Long deviceId) {
        this.deviceId = deviceId;
    }

    public Device getDevice() {
        return device;
    }

    public void setDevice(Device device) {
        this.device = device;
    }

    public Long getRepairmanId() {
        return repairmanId;
    }

    public void setRepairmanId(Long repairmanId) {
        this.repairmanId = repairmanId;
    }

    public User getRepairman() {
        return repairman;
    }

    public void setRepairman(User repairman) {
        this.repairman = repairman;
    }

    public String getRepairmanName() {
        return repairmanName;
    }

    public void setRepairmanName(String repairmanName) {
        this.repairmanName = repairmanName;
    }

    public String getRepairmanPhone() {
        return repairmanPhone;
    }

    public void setRepairmanPhone(String repairmanPhone) {
        this.repairmanPhone = repairmanPhone;
    }

    public Date getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }

    public Date getCompleteTime() {
        return completeTime;
    }

    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }

    public String getRepairCode() {
        return repairCode;
    }

    public void setRepairCode(String repairCode) {
        this.repairCode = repairCode;
    }

    public String getSchool() {
        return this.school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public String getRepairArea() {
        return this.repairArea;
    }

    public void setRepairArea(String repairArea) {
        this.repairArea = repairArea;
    }

    public String getDetailedLocation() {
        return this.detailedLocation;
    }

    public void setDetailedLocation(String detailedLocation) {
        this.detailedLocation = detailedLocation;
    }

    public String getFaultType() {
        return this.faultType;
    }

    public void setFaultType(String faultType) {
        this.faultType = faultType;
    }

    public Long getRepairApplicantId() {
        return this.repairApplicantId;
    }

    public void setRepairApplicantId(Long repairApplicantId) {
        this.repairApplicantId = repairApplicantId;
    }

    public String getRepairApplicantPhone() {
        return this.repairApplicantPhone;
    }

    public void setRepairApplicantPhone(String repairApplicantPhone) {
        this.repairApplicantPhone = repairApplicantPhone;
    }

    public Date getExpectRepairTime() {
        return this.expectRepairTime;
    }

    public void setExpectRepairTime(Date expectRepairTime) {
        this.expectRepairTime = expectRepairTime;
    }

    public Date getRepairTime() {
        return this.repairTime;
    }

    public void setRepairTime(Date repairTime) {
        this.repairTime = repairTime;
    }

    public String getFaultPicture() {
        return this.faultPicture;
    }

    public void setFaultPicture(String faultPicture) {
        this.faultPicture = faultPicture;
    }

    public String getRepairLevel() {
        return this.repairLevel;
    }

    public void setRepairLevel(String repairLevel) {
        this.repairLevel = repairLevel;
    }

    public Integer getCurrentState() {
        return this.currentState;
    }

    public void setCurrentState(Integer currentState) {
        this.currentState = currentState;
    }

    public User getRepairApplicant() {
        return this.repairApplicant;
    }

    public void setRepairApplicant(User repairApplicant) {
        if (repairApplicant == null) {
        } else {
            this.repairApplicantId = repairApplicant.getEid();
            this.repairApplicant = repairApplicant;
        }
    }

    public Date getEvaluateTime() {
        return evaluateTime;
    }

    public void setEvaluateTime(Date evaluateTime) {
        this.evaluateTime = evaluateTime;
    }

    public String getRepairApplicantName() {
        return this.repairApplicantName;
    }

    public void setRepairApplicantName(String repairApplicantName) {
        this.repairApplicantName = repairApplicantName;
    }


}
